﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Utilities;

namespace DownloadAccelerator
{
    class DataStorage : IDataStorage
    {
        private Object[] _data;
        private Mutex mutex = new Mutex();

        public DataStorage(int size)
        {
            _data = new Object[size];
        }

        #region IDataStorage Members

        public object Get(int index)// throw IndexOutOfRangeException, NullPointerException
        {
            mutex.Acquire();
            Object value = _data[index];
            mutex.Release();

            return value;
        }

        public void Set(int index, object value)// throw IndexOutOfRangeException, NullPointerException
        {
            mutex.Acquire();
            _data[index] = value;
            mutex.Release();
        }

        #endregion
    }
}
